﻿using UnityEngine;
using System.Collections;
using System.Diagnostics;
using UnityEngine;

public static class PLDebug
{

    private static float mTimer;
    private static string mTimerStr;

    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void Log(string s)
    {
        UnityEngine.Debug.Log(s);
    }

    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void LogError(string s)
    {
        UnityEngine.Debug.LogError(s);
    }

    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void LogWarning(string s)
    {
        UnityEngine.Debug.LogWarning(s);
    }
    

    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void BeginSample(string s)
    {
        if (UnityEngine.Profiling.Profiler.enabled)
            UnityEngine.Profiling.Profiler.BeginSample(s);
    }

    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void EndSample()
    {
        if (UnityEngine.Profiling.Profiler.enabled)
            UnityEngine.Profiling.Profiler.EndSample();
    }


    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void BeginTimer(string s)
    {
        mTimerStr = s;
        mTimer = Time.realtimeSinceStartup;
    }

    [Conditional("PL_Debug"), Conditional("UNITY_EDITOR")]
    public static void EndTimer()
    {
        Log(string.Format("{0}消耗时间: {1}", mTimerStr, Time.realtimeSinceStartup - mTimer));
    }



}
